<%--
  Created by IntelliJ IDEA.
  User: xugang2
  Date: 2020/7/22
  Time: 15:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<div id="navbar" class="navbar-collapse collapse">
    <ul class="nav navbar-nav navbar-right">
        <li style="padding-top:8px;">
            <div class="btn-group">
                <button type="button" class="btn btn-default btn-success dropdown-toggle" data-toggle="dropdown">
                    <i class="glyphicon glyphicon-user"></i> <sec:authentication property="name"></sec:authentication> <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="#"><i class="glyphicon glyphicon-cog"></i> 个人设置</a></li>
                    <li><a href="#"><i class="glyphicon glyphicon-comment"></i> 消息</a></li>
                    <li class="divider"></li>
                    <%--   a标签点击时，会自动跳转到href值对应的地址 --%>
                    <li><a class="logoutA" href="javascript:void(0);"><i class="glyphicon glyphicon-off"></i> 退出系统</a></li>
                </ul>
            </div>
        </li>

        <li style="margin-left:10px;padding-top:8px;">
            <sec:authorize access="hasAnyRole('BZR - 班主任')">
                <button type="button" class="btn btn-default btn-danger">
                    <span class="glyphicon glyphicon-question-sign"></span> BZR帮助
                </button>
            </sec:authorize>
            <sec:authorize access="hasAnyAuthority('ROLE_PM - 项目经理')">
                <button type="button" class="btn btn-default btn-danger">
                    <span class="glyphicon glyphicon-question-sign"></span> 项目经理帮助
                </button>
            </sec:authorize>
            <sec:authorize access="hasRole('PG - 程序员')">
                <button type="button" class="btn btn-default btn-danger">
                    <span class="glyphicon glyphicon-question-sign"></span> 程序员帮助
                </button>
            </sec:authorize>
        </li>
    </ul>
    <form class="navbar-form navbar-right">
        <input type="text" class="form-control" placeholder="查询">
    </form>
</div>
<form method="post" id="logoutForm" action="${PATH}/logout"></form>
<script type="text/javascript">
    //当文档加载结束后再执行当前代码
    //loginbar代码是在页面的中间静态包含，但是js代码中用到的layer和jquery都是在页面的最后面静态包含的
    window.onload = function () {
        //注销按钮的单击事件
        $(".logoutA").click(function () {
            layer.confirm("你真的要注销吗?" , {"title":"注销确认" ,"icon":3} , function () {
                layer.closeAll();
                //点击确定提交注销请求
                // window.location = "/logout";
                $("#logoutForm").submit();//使用表单提交
            })
        });
    }

</script>
